home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / comm / mail / parsegrabs10.lha / ParseGrabs.br
Text File  |  1995-08-29  |  3KB  |  109 lines

  1. /*
  2. ** $VER: ParseGrabs.br 1.0 (28.8.95)
  3. **
  4. ** ParseGrabs.br will check for any grabs in the download directory and
  5. ** parse them.  If there are active events which have not been deleted it
  6. ** will list these events and then ask the user whether to delete them or
  7. ** not.
  8. **
  9. ** Requires C:List, C:Delete, C:Ask and C:Resident to be present.
  10. **
  11. ** Set makeresident to 1 below for some extra speed.
  12. **
  13. ** Todo:  GUI interface if run from Thor
  14. **
  15. */
  16.  
  17. options results
  18.  
  19.  
  20. pubscreen    = "Workbench"        /* Public screen to open progressbars on,
  21.                                      usually "Workbench" */
  22. makeresident = 1                  /* Make list resident before starting.
  23.                                      0 = FALSE, 1 = TRUE */
  24. remresident  = 1                  /* Remove list from resident list after
  25.                                      finishing. 0 = FALSE, 1 = TRUE */
  26.  
  27.  
  28. /* Open Thor and BBSREAD ARexx ports' */
  29.  
  30. if ~show('p', 'BBSREAD') then do; address command; "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"; "WaitForPort BBSREAD"; end
  31.  
  32. call open(pn, 'ENV:Thor/THORPATH', 'R')
  33. thorpath = readln(pn)
  34. call close(pn)
  35.  
  36. address(bbsread)
  37. GETGLOBALDATA globdata
  38. if rc ~= 0 then do
  39.     say BBSREAD.LASTERROR
  40.     exit(0)
  41.     end
  42.  
  43. GETBBSLIST bbslist
  44. if rc ~= 0 then do
  45.     say BBSREAD.LASTERROR
  46.     exit(0)
  47.     end
  48.  
  49. if makeresident = 1 then address(command) 'Resident C:LIST PURE'
  50.  
  51. if bbslist.COUNT > 0 then do i = 1 to bbslist.COUNT
  52.     address(bbsread)
  53.     GETBBSDATA '"'bbslist.i'"' bbsdata
  54.     if rc ~= 0 then do
  55.         say BBSREAD.LASTERROR
  56.         exit(0)
  57.         end
  58.  
  59.     if bbsdata.DNLOADPATH ~= '' then dlpath = bbsdata.DNLOADPATH
  60.     else dlpath = globdata.DNLOADPATH
  61.  
  62.     address(command)
  63.     'List >T:GrabList 'dlpath || bbsdata.GRABNAME'#? LFORMAT "%s"'
  64.  
  65.     if exists("T:GrabList") then do
  66.         call open(gl, "T:GrabList", 'R')
  67.         do until eof(gl)
  68.             entry = readln(gl)
  69.             if entry ~= '' then do
  70.                 say '1B'x'[1mParsing 'bbsdata.BBSTYPE' grab from 'bbsdata.NAME': "'dlpath || entry'"' || '1B'x'[0m'
  71.  
  72.                 if bbsdata.NUMEVENTS > 0 then do
  73.                     readkbd:
  74.                     say 'There are active events on "'bbsdata.NAME'":'
  75.                     thorpath'bin/ListEvents "'bbsdata.NAME'" FULL'
  76.                     'Ask "*NDelete these events? [y/N]"'
  77.  
  78.                     if rc = 5 then do
  79.                         thorpath'bin/ScriptServ "'bbsdata.NAME'" PACKAGEDONE'
  80.                         address(bbsread)
  81.                         GETBBSDATA '"'bbslist.i'"' bbsdata
  82.                         address(command)
  83.                         if bbsdata.UPLOADPATH ~= '' then ulpath = bbsdata.UPLOADPATH
  84.                         else ulpath = globdata.UPLOADPATH
  85.                         'Delete "'ulpath||bbsdata.REPLYPACKET'" QUIET FORCE'
  86.                         end
  87.                     end
  88.  
  89.                 thorpath'bin/CfgType >T:TypeInfo 'bbsdata.BBSTYPE
  90.  
  91.                 call open(ti, "T:TypeInfo", 'R')
  92.                 tmp = readln(ti); tmp = readln(ti); tmp = readln(ti); tmp = readln(ti)
  93.                 parser = subword(tmp, 4); parser = left(parser, index(parser, ',') - 1)
  94.                 call close(ti)
  95.  
  96.                 thorpath || parser' "'bbsdata.NAME'" "'dlpath || entry'" ARCHIVE DELETE PUBSCREEN "'pubscreen'"'
  97.                 end
  98.             end
  99.         call close(gl)
  100.         end
  101.     end
  102.  
  103. address(command)
  104. if exists("T:GrabList") then 'Delete T:GrabList QUIET'
  105. if exists("T:TypeInfo") then 'Delete T:TypeInfo QUIET'
  106. exit(0)
  107.  
  108. if remresident = 1 then 'Resident C:LIST REMOVE'
  109.